package framework;

import java.util.ArrayList;

public class StringTool {
	char[] arr;
	public StringTool(){
		arr = null;
	}
	
	public String reverseString(String str){
		arr = str.toCharArray();
		int begin = 0;
		int end = arr.length - 1;
		while(begin < end){
			char temp = arr[begin];
			arr[begin] = arr[end];
			arr[end] = temp;
			begin++;
			end--;
		}
		
		return new String(arr);
	}
	
	public ArrayList<String> splitString(String str,char regex){
		arr = str.toCharArray();
		ArrayList<String> result = new ArrayList<>();
		StringBuilder sb = new StringBuilder();
		for(int i = 0;i < arr.length ;i++){
			if(arr[i] != regex){
				sb.append(arr[i]);
			}else{
				result.add(sb.toString());
				sb.setLength(0);
			}
		}
		result.add(sb.toString());
		return result;
	}
}
